import { AppDispatch } from '..';
import { getAllChannelApi, getUserChannelsAPI } from '@/api/channel';

/** 获取所有频道的Action */
export const getAllChannelAction = () => {
  return async (dispatch: AppDispatch) => {
    const res = await getAllChannelApi();
    console.log('11,user', res);
    dispatch({ type: 'channel/saveChannels', payload: res.data.channels });
  };
};

// 2. 封装异步Action
export const getUserChannelAction = () => {
  return async (dispatch: AppDispatch) => {
    const res = await getUserChannelsAPI();
    console.log('res  ----->  ', res);
    dispatch({ type: 'channel/saveUserChannels', payload: res.data.channels });
  };
};
